//////////////////////////////////////////////////////////////////////
//
// Huffman_private.h is only shared in Huffman_*.c.
// It declares private methods and fields of Huffman Family.
//
//////////////////////////////////////////////////////////////////////
#ifndef __HUFFMAN_PRIVATE_H__
#define __HUFFMAN_PRIVATE_H__

#include "Huffman.h"

typedef struct CHuffmanNode_struct
{
	int nFrequency; // must be first for byte align
	UBYTE byAscii;
	int nCodeLength;
	DWORD dwCode;	
	struct CHuffmanNode_struct *pParent, *pLeft, *pRight;
} CHuffmanNode;

extern void* global_huffman_tree;

int __cdecl frequencyCompare(const void *elem1, const void *elem2 );
int __cdecl asciiCompare(const void *elem1, const void *elem2 );
int __cdecl asciiCompareForPointerArray(const void *elem1, const void *elem2);

CHuffmanNode* PopNode(CHuffmanNode *pNodes[], int nIndex, BOOL bRight);

#ifdef WINDOWS_MAKE

void SetNodeCode(CHuffmanNode* pNode);
HuffmanTree ConvertCHuffmanNodes2HuffmanTree(CHuffmanNode* chuffnodes, int count);

#endif

#endif